package dao;

import java.util.List;

import model.Invoice;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class StatisticDAO {
	private final SessionFactory sf = util.NewHibernateUtil.getSessionFactory();

	@SuppressWarnings("unchecked")
	public List<Invoice> showAllInvoice() {
		try {
			Session session = sf.getCurrentSession();
			session.beginTransaction();
			String hql = "from Invoice";
			Query q = session.createQuery(hql);
			List<Invoice> list = q.list();
			session.getTransaction().commit();
			return list;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
